<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/static/include/topLess.jsp"%>

<link href="${baseURL}/static/css/Pager.css" rel="stylesheet" type="text/css" />
<script src="${baseURL}/static/js/jquery.pager.js"></script>

<table>
		<tbody>
			<tr class="tab_grey">
				<td>
				<form name="searchForm" action="${baseURL}/audit/queryIndicator" method="post">
					<input type="hidden" name="p" value="1" />

				<span class="tab_text">报表制度：</span>
				<select id="versionSystem" name="versionSystem" class="tab_textbut">
					<option value="">请选择..</option>
					<c:forEach items="${requestScope.typeList}" var="vs">
					<option value="${vs.code}">${vs.codeName}</option>
					</c:forEach>
				</select>  
	
				
				<span class="tab_text">产业主要类别：</span>
				<select id="majorList" name="majorList" class="tab_textbut">
					<option value="">请选择..</option>
					<option value="1">主要海洋产业</option>
					<option value="2">海洋科研教育管理服务业</option>
					<option value="3">海洋相关产业</option>
				</select>  
				
				<span class="tab_text">产业分类：</span>
				<select id="dustryList" name="dustryList" class="tab_textbut_200">
					<option value="">请选择..</option>
				</select>  
				
				
				<br/>
				
				<span class="tab_text">指标名称：</span>
				<input id="indicatorName" name="indicatorName" type="text" class="tab_textbut_200" />
				
				<span class="tab_text">指标代码：</span>
				<input id="indicatorCode" name="indicatorCode" type="text" class="tab_textbut_200" />
				
				<a class="tab_but" href="#" onclick="selectIndicator(1);">查询</a>

				<a class="tab_but" href="#" onclick="saveSel()">保存</a>
			</form>
				</td>
			</tr>
		</tbody>
</table>


<div style="width:900px;margin:0 auto;">
	<div style="width:400px; float: left">
		选择列表：<br/>
		<select id="leftSel" class="tab_textbut_300" style="height:320px;width:400px" size="20" ondblclick="selectToRight()" multiple="multiple">
		</select>
		<div id="pager"></div>  
	</div>
	<div style="width:95px; float:left; padding:150px 0; text-align: center " >
		<button onclick="selectToRight()">---&gt;</button>
		<br/>
		<br/>
		<button onclick="delSel()">&lt;---</button>
	</div>
	<div style="width:400px; float: left">
		保存列表：<br/>
		<select id="rightSel" class="tab_textbut_300" style="height:320px;width:400px" size="20" ondblclick="delSel()" multiple="multiple">
		
		</select>
	</div>
</div>




<script language="javaScript">

var totalPages = 0;

	$().ready(function(){

		$("#versionSystem").bind("change", function(){
			if (this.value=="2"){	//海洋生产总值核算制度
				$("#majorList").attr("disabled", true);
				$("#dustryList").attr("disabled", true);
			}else{
				$("#majorList").attr("disabled", false);
				$("#dustryList").attr("disabled", false);
			}
		});
		
		
		$("#majorList").bind("change", function(){			
			industrySelect(this.value);			
		});

	});
	
	//查询并过滤产业分类信息
	function industrySelect(major){
		$("#dustryList").empty();
		$("#dustryList").append("<option value=''>请选择..</option>");
		var url = "${baseURL}/industryManage/allList";
		$.getJSON(url, function(result){

			$.each(result.operationResult, function(i, obj){
				
				if (obj.code==major){
					$("#dustryList").append("<option value='" + obj.dl + "'>" + obj.dustryName + "</option>");
				}
				
			});
		});
	}
	
	//指标查询
	function selectIndicator(pagenumber){
		
		if ($("#versionSystem").val()==""){
			layer.alert("请选择报表制度");
			return;
		}
		
		var url = "${baseURL}/audit/queryIndicators";
		var data = "statSystem=" + $("#versionSystem").val() + "&industryCode=" + $("#dustryList").val() + "&indicatorName=" + $("#indicatorName").val() 
		 + "&indicatorCode=" + $("#indicatorCode").val() + "&pageNum=" + pagenumber;
		
		$.ajax({
			url:url,
			type:'post',
			data:data, 
			dataType:'json',
			success:function(msg){
				
				$("#leftSel").empty();
				totalPages = 0;
				
				if (msg.totalCount % msg.pageSize == 0){
					totalPages = msg.totalCount / msg.pageSize;
				}else{
					totalPages = Number(msg.totalCount / msg.pageSize) + 1;
				}
				$("#pager").pager({ pagenumber: pagenumber, pagecount: totalPages, buttonClickCallback: PageClick });
				
				$.each(msg.operationResult, function(i, obj){
					$("#leftSel").append("<option value='" + obj.indicatorType + "_" +  obj.id + "' title='" + obj.name + "'>" + obj.code + "：" + obj.name + "</option>");
				});
				
				
				if (msg.totalCount<=msg.pageSize){
					$("#pager").css("display", "none");
				}
				
			}
		});
	}
	
    PageClick = function(pageclickednumber) {
    	selectIndicator(pageclickednumber);
    }
    
    //从左边列表选择到右边列表
    function selectToRight(){
    	
    	var options = $("#leftSel option:selected");
    	
    	if ($(options).val()!=""){    		
    		$.each(options, function(i, option){
        		if ($("#rightSel option[value='" + $(option).val() + "']").val()==undefined){        			
        			$("#rightSel").append("<option value='" + $(option).val() + "'>" + $(option).text() +"</option>");
        		}
    		});
    	}
    }
    
    function delSel(){
    	var options = $("#rightSel option:selected");
    	options.remove();
    }
    
    //保存已选择的指标
    function saveSel(){
    	var indicator = new Array();
    	var options = $("#rightSel option");
    	
    	if (options.length==0){
    		layer.alert("请选择指标");
    		return;
    	}
    	
    	$.each(options, function(i, option){
    		indicator.push(option.value);
    	});
    	closeWin(indicator);
    }

</script>

<%@ include file="/static/include/bottom.jsp"%>